package com.hqd.ch03.v11.spel.exception;

public class SpelParseException extends ParseException {

    private final SpelMessage message;

    private final Object[] inserts;


    public SpelParseException(String expressionString, int position, SpelMessage message, Object... inserts) {
        super(expressionString, position, message.formatMessage(inserts));
        this.message = message;
        this.inserts = inserts;
    }

    public SpelParseException(int position, SpelMessage message, Object... inserts) {
        super(position, message.formatMessage(inserts));
        this.message = message;
        this.inserts = inserts;
    }

    public SpelParseException(int position, Throwable cause, SpelMessage message, Object... inserts) {
        super(position, message.formatMessage(inserts), cause);
        this.message = message;
        this.inserts = inserts;
    }


    /**
     * Return the message code.
     */
    public SpelMessage getMessageCode() {
        return this.message;
    }

    /**
     * Return the message inserts.
     */
    public Object[] getInserts() {
        return this.inserts;
    }

}

